<!DOCTYPE html>
<html>
{include file="head.html"}
<body>
<div class="fullscreen">
  <div class="scroll_content">
    <div class="topfixed">
      <div class="t_left"><a href="/index.php?m=user&a=edilist"><i class="back"></i></a></div>
      <div class="t_main">修改头像</div>
    </div>
      {include file="user/incuser.html"}
  <div class="main-body">
<div class="row">
 <form method="post" id="user-form" action="/index.php?m=user&a=User_head_save">
 

<div class="comblock">
                <table class="order_pingjia_table">

                    <tr>
                        <th>头像：</th>
                        <td><a href="javascript:;" class="upload">
                                <input type="file" name="Filedata"  name="upimg" id="upimg"  id="filedata" style="width:30px;height:30px;font-size:30px;opacity:0;">
                            </a>
                             <div  id="uploading" style="color:red; display:none;">正在上传中...</div>
      <input type="hidden" name="user_head" id="imgurl" value="{$user.user_head}">
      
      <div id="imgShow">
      {if $user.user_head}
      <img src="{const.IMAGES_SITE}{$user.user_head}.100x100.jpg">
      {/if}
      </div>
                            </td>
                    </tr>
                </table>
            </div>
            <button id="edi-submit" type="button" class="cart_change_btn">保存</button>
 </form>           
            
  
 
<script src="/plugin/skyweb/lrz.mobile.min.js"></script>
<script>
var input = document.querySelector('#upimg');

input.onchange = function () {
    // 也可以传入图片路径：lrz('../demo.jpg', ...
	$("#uploading").show();
    lrz(this.files[0],{width:1024}, function (results) {
      // 你需要的数据都在这里，可以以字符串的形式传送base64给服务端转存为图片。
      console.log(results);
	  $.post("/index.php?m=upload&a=base64",{content:results.base64},function(data){
		  $("#imgShow").html('<img src="'+data.imgurl+'.100x100.jpg">');
		  $("#imgurl").val(data.file); 
		   $("#uploading").hide();
	  },"json");
	  
	 
    });
}

$(function(){
	$("#edi-submit").on(CLICK,function(){
		$.post("/index.php?m=user&a=User_head_save&ajax=1",$("#user-form").serialize(),function(data){
			if(data.error){
				skyToast(data.message);
			}else{
				skyToast("保存成功");
			}
		},"json");
	});
});
</script>
</div>
</div>
 
</div>
{include file="footer.html"}
</div>
</body>
</html>